package com.chenxin.wms.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chenxin.common.utils.ConvertUtils;
import com.chenxin.wms.domain.po.SupplierInfo;
import com.chenxin.wms.domain.vo.SupplierVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.chenxin.wms.mapper.SupplierMapper;
import com.chenxin.wms.domain.SupplierEntity;
import com.chenxin.wms.service.ISupplierService;

/**
 * 供应商资料Service业务层处理
 *
 * @author gry
 * @date 2025-04-10
 */
@Service
public class SupplierServiceImpl implements ISupplierService {
    @Autowired
    private SupplierMapper supplierMapper;

    /**
     * 查询供应商资料
     *
     * @param supplierId 供应商资料主键
     * @return 供应商资料
     */
    @Override
    public SupplierEntity selectSupplierBySupplierId(Long supplierId) {
        return supplierMapper.selectById(supplierId);
    }

    @Override
    public SupplierEntity selectSupplierBySupplierNo(String supplierNo) {
        QueryWrapper<SupplierEntity> supplierQW = new QueryWrapper<>();
        supplierQW.eq("supplier_no", supplierNo).last("limit 1");
        return supplierMapper.selectOne(supplierQW);
    }

    /**
     * 查询供应商资料列表
     *
     * @param supplierEntity 供应商资料
     * @return 供应商资料
     */
    @Override
    public List<SupplierVO> selectSupplierList(SupplierEntity supplierEntity) {
        return supplierMapper.selectSupplierViewList(supplierEntity);
    }

    /**
     * 新增供应商资料
     *
     * @param supplierEntity 供应商资料
     * @return 结果
     */
    @Override
    public int insertSupplier(SupplierEntity supplierEntity) {
        return supplierMapper.insert(supplierEntity);
    }

    /**
     * 修改供应商资料
     *
     * @param supplierEntity 供应商资料
     * @return 结果
     */
    @Override
    public int updateSupplier(SupplierEntity supplierEntity) {
        return supplierMapper.updateById(supplierEntity);
    }

    /**
     * 批量删除供应商资料
     *
     * @param supplierIds 需要删除的供应商资料主键
     * @return 结果
     */
    @Override
    public int deleteSupplierBySupplierIds(Long[] supplierIds) {
        return supplierMapper.deleteSupplierBySupplierIds(supplierIds);
    }
}
